<?php

$admin_url = base_url('otakkanan');
$kirim_url = base_url('otakkiri');

$mapdir = "<a href='$admin_url/' class='taut'>Home</a> &gt; ";
$other_head = "";

$menu = $this->uri->segment(3, "all");

switch($menu)
{
	case "baru":
		$mapdir .= "
			<a href='$admin_url/kategori' class='taut'>Kategori Usaha</a>
			&gt; 
			<b>Kategori Baru</b>
		";
		
		$isipage = "
				<div id='content2'>
						<h3>Kategori Baru</h3>
							<div class='isicontent2'>
							
							  <form id='FrmMasukan' action='$kirim_url/kategoribaru' method='post' onsubmit='return validasi_kategori(this)'>
								
									<table>
										<tbody>
											<tr>
												<td class='left'>Nama Kategori</td>
												<td class='right'>: <input name='kategori' type='text' placeholder='Nama Kategori' /></td>
											</tr>
											<tr>
												<td class='left'>&nbsp;</td>
												<td class='right'>&nbsp;</td>
											</tr>
											<tr>
												<td class='left'> &nbsp; </td>
												<td class='right'>
												<input type='submit' value='Buat'> &nbsp; 
												<input type='reset' value='Ulang'>
												</td>
											</tr>
										
										</tbody>
									</table>
									
							  </form>
							</div>
							
						</div>
			";
		
	;
	break;
	
	case "edit":
		$mapdir .= "
			<a href='$admin_url/kategori' class='taut'>Kategori Usaha</a>
			&gt; 
			<b>Edit Kategori</b>
		";
		
		$idkat = $this->input->get('idkat');
		$hasil = $this->adminmodel->get_data_kategori($idkat);
		
		if($hasil !== FALSE)
		{
			foreach($hasil AS $hasil2){
				$idkat = $hasil2->idkategori;
				$kategori = html_escape($hasil2->kategori);
				
				$tampil = "<tr>
								<td class='left'>Nama Kategori</td>
								<td class='right'>: <input name='kategori' type='text' value='$kategori' /></td>
							</tr>
							<tr>
								<td class='left'>&nbsp;</td>
								<td class='right'>&nbsp;</td>
							</tr>
							<tr>
								<td class='left'> &nbsp; </td>
								<td class='right'>
								<input name='idkategori' type='hidden' value='$idkat' />
								<input type='submit' value='Buat'> &nbsp; <input type='reset' value='Ulang'></td>
							</tr>";
			}
		}else{
			$tampil = "<tr>
							<td class='left'>&nbsp;</td>
							<td class='right'>Kategori Tidak Ditemukan</td>
						</tr>";
		}
		
		$isipage = "
				<div id='content2'>
						<h3>Kategori Baru</h3>
							<div class='isicontent2'>
							
							  <form id='FrmMasukan' action='$kirim_url/updatekategori' method='post' onsubmit='return validasi_kategori(this)'>
								
									<table>
										<tbody>
										
											$tampil
										
										</tbody>
									</table>
									
							  </form>
							</div>
							
						</div>
			";
	;
	break;
	
	
	
	default:
		$mapdir .= "
			<b>Kategori Usaha</b>
		";
		
		$awal = $this->input->get("awal");
		$kategori = $this->adminmodel->get_kategori($awal);
		$datakat = "";
		
		if($kategori !== FALSE)
		{
			foreach($kategori AS $katdata)
			{
				$idkat = $katdata->idkategori;
				$kategori = $katdata->kategori;
				
				$datakat .= "<tr>
					<td class='left'>$kategori</td>
					<td class='right'>
						<a href='$admin_url/kategori/edit?idkat=$idkat' class='taut'>Edit</a> &nbsp; 
						<a href='$kirim_url/hapuskategori?idkat=$idkat' onclick='return konfirmhapus()' title='Menghapus Kategori juga akan menghapus semua perusahaan didalamnya'>Hapus</a>
					</td>
					</tr>";
			}
		}else{
			$datakat .= "
			<tr>
				<td class='left'>&nbsp;</td>
				<td class='right'>
					Belum ada data Kategori. <a href='$admin_url/kategori/baru'>Buat kategori?</a>
				</td>
			</tr>";
		}
		
		$config['base_url'] = $admin_url.'/kategori?kat=usaha';
		$config['total_rows'] = $this->adminmodel->hitung_data('idkategori','dn_category');
		$config['per_page'] = 10; 
		$config['anchor_class'] = 'class="taut"';
		$config['page_query_string'] = TRUE;
		$config['query_string_segment'] = 'awal';

		$this->pagination->initialize($config); 
		$halaman = $this->pagination->create_links();
		
		$isipage = "
				<div id='content2'>
						<h3>Kategori Usaha</h3>
							<div class='isicontent2'>
							 <table>
								<tbody>
									<tr><td class='left'><a href='$admin_url/kategori/baru' class='taut'>Kategori Baru</a></td><td class='right'>&nbsp;</td></tr>
									<tr><td class='left'>&nbsp;</td><td class='right'>&nbsp;</td></tr>
									$datakat
									<tr><td class='left'>&nbsp;</td><td class='right'>&nbsp;</td></tr>
									<tr><td class='left'><a href='$admin_url/kategori/baru' class='taut'>Kategori Baru</a></td><td class='right'>$halaman</td></tr>
								</tbody>
							 </table>
							</div>
							
					</div>
			";
	;
	break;
}


$data['map_dir'] = $mapdir;
$data['isi_page'] = $isipage;
$data['site_title'] = 'Kategori Usaha - Dadan Network';
$data['base_url'] = base_url();
$data['tahun_sekarang'] = date("Y");

$this->parser->parse('template/admin', $data);


/* End of file kategori.php */
/* Location: ./application/views/admin/kategori.php */
